import { create } from 'zustand'
import {IUser} from '@/types/api.ts'
export const useStore = create<{
  collapsed: boolean;
  updateCollapsed: () => void;
  currentMenu: string;
  userInfo: IUser;
  updateUserInfo: (userInfo: IUser) => void;
  setCurrentMenu: (menu: string) => void;
}>((set) => ({
  // 是否缩小左边菜单
  collapsed: false,
  userInfo: {
    _id: '',
    userId: 0,
    userName: '',
    userEmail: '',
    deptId: '',
    state: 0,
    mobile: '',
    job: '',
    role: 0,
    roleList: '',
    createId: 0,
    deptName: '',
    userImg: '',
  },
  updateCollapsed: () => set((state) => ({ collapsed: !state.collapsed })),
  updateUserInfo: (userInfo: IUser) => set({ userInfo }),
  //左边选中的菜单
  currentMenu: '/dashboard',
  setCurrentMenu: (menu: string) => set({ currentMenu: menu }),
}))
